Conversation
| Tensor<T> t1(s1); | ||
|
|
||
| REQUIRE(t1.shape == s1); | ||
| REQUIRE(t1.data == AlignedPtr<T>(s1.total())); |
There was a problem hiding this comment.
I don't think the content of the pointer is guaranteed to match between allocations. It would be better to test that the length of data == s1.total()
| TEST_CASE_TEMPLATE("Tensor(Shape&, PtrType&)", T, test_data_types) | ||
| { | ||
| Shape s1; | ||
| AlignedPtr<T> ptr1; |
There was a problem hiding this comment.
This is an empty pointer and empty shape. The test would be better if you set the shape and filled the pointer with some values. For example-
Shape s1 = Shape{2, 2};
AlignedPtr<T> ptr1 = {1, 2, 3, 4};
Then you can explicitly test if tensor shape == {2, 2} and aligned ptr data = {1, 2, 3, 4}
…al projection function that returns vector projected onto line L spanned by vector s.
JordanCheney
left a comment
There was a problem hiding this comment.
The new methods are really cool!
| inline Tensor<DataType> gaussian_elim(Tensor<DataType>& T1) | ||
| { | ||
| static_assert(std::is_floating_point<DataType>::value, | ||
| "eigenvalues() requires signed data"); |
There was a problem hiding this comment.
I think you forgot to change eigenvalues() :)
| } | ||
|
|
||
| template <typename DataType> | ||
| inline Tensor<DataType> gaussian_elim(Tensor<DataType>& T1, Tensor<DataType>& V1) |
There was a problem hiding this comment.
Can you add documentation for the 2 tensor case
| TNT_ASSERT(T1.shape.num_axes() == 2, InvalidParameterException("tnt::gaussian_elim()", | ||
| __FILE__, __LINE__, "Gaussian elimination requires 2D tensors")) | ||
|
|
||
| return detail::OptimizedGaussianElimination<DataType>::eval(T1); |
| } | ||
|
|
||
| if (ptr[lead] == 1) { | ||
| clearColumn(ptr, i, (lead - (num_cols * i)), num_rows, num_cols, vct); |
There was a problem hiding this comment.
super nitpicky but I like functions to be lowercase_underscore instead of camel case
|
|
||
| static void divideVector(DataType* vct, int row, DataType value) | ||
| { | ||
| vct[row] = vct[row] - value; |
There was a problem hiding this comment.
Is it expected that vct is updated in place? Meaning if I pass in 2 tensors should I expect both to change?
| DataType* s = V2.data.data; | ||
| int num_rows = V1.shape.axes[ROW_INDEX]; | ||
|
|
||
| scalar_multiply(s, (dotProduct(v, s, num_rows) / dotProduct(s, s, num_rows)), num_rows); |
There was a problem hiding this comment.
You can just do V2 * dotProduct(...). Scalar multiplication is a method for tensors and should be faster then your version (it uses SIMD)
| template <typename DataType, typename Enable = void> | ||
| struct OptimizedOrthogonalProjection | ||
| { | ||
| static Tensor<DataType> eval(const Tensor<DataType>&, const Tensor<DataType>&); |
There was a problem hiding this comment.
The inputs are const here but not in your *_impl.hpp file. I think they should be const in both places
| /// \requires V1 and V2 shall be one dimensional | ||
|
|
||
| template <typename DataType> | ||
| inline Tensor<DataType> project(Tensor<DataType>& V1, Tensor<DataType> V2) |
There was a problem hiding this comment.
I think the inputs should be const here as well
No description provided.